//
//  RequestAPI.m
//  Baymax
//
//  Created by jolin on 16/4/18.
//  Copyright © 2016年 jolin. All rights reserved.
//

#import "RequestAPI.h"
#import "HttpManagerTask.h"
#import "Header.h"
#import "UserInfo.h"

@implementation RequestAPI

#pragma mark - 用户登录
- (void)userLoginWithUsername:(NSString *)username password:(NSString *)password result:(result)result{
    NSDictionary *parameters = @{@"username":username, @"password":password};
    NSString *urlString = [NSString stringWithFormat:@"%@/api-token-auth/",BASEURLCONATANS];
    
    __block NSMutableArray *array = [NSMutableArray array];
    [[HttpManagerTask sharedHttpManager]HttpTaskWithURLString:urlString requestType:@"post" parameters:parameters result:^(NSArray *resultArr, NSError *error) {
//        NSLog(@"%@",resultArr);
        array = [NSMutableArray arrayWithArray:resultArr];
        result(array,error);
    }];
    //get200 post201 put 201 delete204
}

#pragma mark - 用户注册
- (NSArray *)userRegistWithUserInfo:(UserInfo *)user {
    NSDictionary *parameters = [CommenTools getDicWithModel:user];
    //NSLog(@"%@",dic);
    NSString *urlStr = [NSString stringWithFormat:@"%@/user/",BASEURL];
    __block NSMutableArray *array = [NSMutableArray array];
    [[HttpManagerTask sharedHttpManager]HttpTaskWithURLString:urlStr requestType:@"post" parameters:parameters result:^(NSArray *resultArr, NSError *error) {
        NSLog(@"%@",resultArr);
        array = [NSMutableArray arrayWithArray:resultArr];
    }];
    return array;
}


@end
